gdk: Allow passing the start coordinates in drag_begin
authorMatthias Clasen <mclasen@redhat.com>
Mon, 7 Dec 2015 18:47:45 +0000 (13:47 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 13 Dec 2015 15:39:43 +0000 (10:39 -0500)
Add a variant of gdk_drag_begin that takes the start position
in addition to the device. All backend implementation have been
updated to accept (and ignore) the new arguments.

Subsequent commits will make use of the data in some backends.

14 files changed:
docs/reference/gdk/gdk3-sections.txt
gdk/broadway/gdkdnd-broadway.c
gdk/broadway/gdkprivate-broadway.h
gdk/gdkdnd.h
gdk/gdkwindow.c
gdk/gdkwindowimpl.h
gdk/quartz/gdkdnd-quartz.c
gdk/quartz/gdkprivate-quartz.h
gdk/wayland/gdkdnd-wayland.c
gdk/wayland/gdkprivate-wayland.h
gdk/win32/gdkdnd-win32.c
gdk/win32/gdkprivate-win32.h
gdk/x11/gdkdnd-x11.c
gdk/x11/gdkprivate-x11.h

index a2ab5d8c17b53f04a34493d9bfa3c8c92c4d7909..414cf26e9d1f6e458e4df5d0fe54f9451c76b87f 100644 (file)
@@ -950,6 +950,7 @@ gdk_drag_drop
 gdk_drag_find_window_for_screen
 gdk_drag_begin
 gdk_drag_begin_for_device
+gdk_drag_begin_from_point
 gdk_drag_motion
 gdk_drop_finish
 GdkDragProtocol
index 06dcd8f945809602af3681a925cda7561ca4a228..042a0cd65b5fe6e880affb71038e0600ae9fb5ff 100644 (file)
@@ -87,7 +87,9 @@ gdk_broadway_drag_context_finalize (GObject *object)
 GdkDragContext *
 _gdk_broadway_window_drag_begin (GdkWindow *window,
                                 GdkDevice *device,
-                                GList     *targets)
+                                GList     *targets,
+                                 gint       x_root,
+                                 gint       y_root)
 {
   GdkDragContext *new_context;
 
index 45a1c827b17c1ab08b83f66124bc37a5f851b12f..aa52ccbb33083a1597f93160fb7fefd4be3e10ff 100644 (file)
@@ -44,7 +44,9 @@ void _gdk_broadway_resync_windows (void);
 void     _gdk_broadway_window_register_dnd (GdkWindow      *window);
 GdkDragContext * _gdk_broadway_window_drag_begin (GdkWindow *window,
                                                  GdkDevice *device,
-                                                 GList     *targets);
+                                                 GList     *targets,
+                                                  gint       x_root,
+                                                  gint       y_root);
 void     _gdk_broadway_window_translate         (GdkWindow *window,
                                                 cairo_region_t *area,
                                                 gint       dx,
index bcac0a6f9fb1db2df5815e56960918d28ffed9bb..12a817fc753452c887d6c61c27da46631f726ecb 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <gdk/gdktypes.h>
 #include <gdk/gdkdevice.h>
+#include <gdk/gdkevents.h>
 
 G_BEGIN_DECLS
 
@@ -143,6 +144,12 @@ GDK_AVAILABLE_IN_ALL
 GdkDragContext * gdk_drag_begin_for_device (GdkWindow      *window,
                                             GdkDevice      *device,
                                             GList          *targets);
+GDK_AVAILABLE_IN_3_20
+GdkDragContext * gdk_drag_begin_from_point  (GdkWindow      *window,
+                                             GdkDevice      *device,
+                                             GList          *targets,
+                                             gint            x_root,
+                                             gint            y_root);
 
 GDK_AVAILABLE_IN_ALL
 void    gdk_drag_find_window_for_screen   (GdkDragContext   *context,
index 7e2dfb72c3641fd5fda4cb9039a704cce64270eb..bd32ad12c74682dc3dab89831c3844e9699403f1 100644 (file)
@@ -11014,11 +11014,42 @@ gdk_drag_begin (GdkWindow     *window,
  * Returns: (transfer full): a newly created #GdkDragContext
  */
 GdkDragContext *
-gdk_drag_begin_for_device (GdkWindow     *window,
-                           GdkDevice     *device,
-                           GList         *targets)
+gdk_drag_begin_for_device (GdkWindow *window,
+                           GdkDevice *device,
+                           GList     *targets)
 {
-  return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->drag_begin (window, device, targets);
+  gint x, y;
+
+  gdk_device_get_position (device, NULL, &x, &y);
+
+  return gdk_drag_begin_from_point (window, device, targets, x, y);
+}
+
+/**
+ * gdk_drag_begin_from_point:
+ * @window: the source window for this drag
+ * @device: the device that controls this drag
+ * @targets: (transfer none) (element-type GdkAtom): the offered targets,
+ *     as list of #GdkAtoms
+ * @x_root: the x coordinate where the drag nominally started
+ * @y_root: the y coordinate where the drag nominally started
+ *
+ * Starts a drag and creates a new drag context for it.
+ *
+ * This function is called by the drag source.
+ *
+ * Returns: (transfer full): a newly created #GdkDragContext
+ *
+ * Since: 3.20
+ */
+GdkDragContext *
+gdk_drag_begin_from_point (GdkWindow *window,
+                           GdkDevice *device,
+                           GList     *targets,
+                           gint       x_root,
+                           gint       y_root)
+{
+  return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->drag_begin (window, device, targets, x_root, y_root);
 }
 
 /**
index 07a307c269a36b48bdf69a7dd35367e8624437b1..f0743434fcb010e33e9baf3371f0619ca5c3af27 100644 (file)
@@ -239,7 +239,9 @@ struct _GdkWindowImplClass
   void         (* register_dnd)         (GdkWindow *window);
   GdkDragContext * (*drag_begin)        (GdkWindow *window,
                                          GdkDevice *device,
-                                         GList     *targets);
+                                         GList     *targets,
+                                         gint       x_root,
+                                         gint       y_root);
 
   void         (*process_updates_recurse) (GdkWindow      *window,
                                            cairo_region_t *region);
index bb4a8f3b9a88a8eda7412f5f0338616986b0199e..0a38cd892eabf84be5c13358874ef968c871695c 100644 (file)
@@ -35,7 +35,9 @@ gdk_quartz_drag_source_context ()
 GdkDragContext *
 _gdk_quartz_window_drag_begin (GdkWindow *window,
                                GdkDevice *device,
-                               GList     *targets)
+                               GList     *targets,
+                               gint       x_root,
+                               gint       y_root)
 {
   g_assert (_gdk_quartz_drag_source_context == NULL);
 
index 5d2fcc1517441e5463837e9a1099b3e5ddca34e4..1a7410cb1d34e34d58ed1bb8369034db70f4b48a 100644 (file)
@@ -80,7 +80,9 @@ void         _gdk_quartz_synthesize_null_key_event (GdkWindow *window);
 void        _gdk_quartz_window_register_dnd      (GdkWindow   *window);
 GdkDragContext * _gdk_quartz_window_drag_begin   (GdkWindow   *window,
                                                   GdkDevice   *device,
-                                                  GList       *targets);
+                                                  GList       *targets,
+                                                  gint         x_root,
+                                                  gint         y_root);
 
 /* Display */
 
index fd0d0a3c068af01775aa4e57c1347020ef3aa9cd..36259e933a22dada7a0bb2bc2fab75002151d125 100644 (file)
@@ -375,7 +375,9 @@ create_dnd_window (GdkScreen *screen)
 GdkDragContext *
 _gdk_wayland_window_drag_begin (GdkWindow *window,
                                GdkDevice *device,
-                               GList     *targets)
+                               GList     *targets,
+                                gint       x_root,
+                                gint       y_root)
 {
   GdkWaylandDragContext *context_wayland;
   GdkWaylandDisplay *display_wayland;
index c4b51856434e39809a52fefc833ad0abe19abebb..0e486f839a4531ef65163f6122963c0f29a6ab0d 100644 (file)
@@ -103,11 +103,12 @@ GdkDragProtocol _gdk_wayland_window_get_drag_protocol (GdkWindow *window,
 void            _gdk_wayland_window_register_dnd (GdkWindow *window);
 GdkDragContext *_gdk_wayland_window_drag_begin (GdkWindow *window,
                                                GdkDevice *device,
-                                               GList     *targets);
+                                               GList     *targets,
+                                                gint       x_root,
+                                                gint       y_root);
 void            _gdk_wayland_window_offset_next_wl_buffer (GdkWindow *window,
                                                            int        x,
                                                            int        y);
-
 GdkDragContext * _gdk_wayland_drop_context_new (struct wl_data_device *data_device);
 void _gdk_wayland_drag_context_set_source_window (GdkDragContext *context,
                                                   GdkWindow      *window);
index ca658ccfcd082bc85526a573819f98a9f99c5583..f0a1f97869cb7bd97bdce10e3ea9d81fbca3f9c7 100644 (file)
@@ -1807,7 +1807,9 @@ gdk_drag_do_leave (GdkDragContext *context,
 GdkDragContext *
 _gdk_win32_window_drag_begin (GdkWindow *window,
                              GdkDevice *device,
-                             GList     *targets)
+                             GList     *targets,
+                              gint       x_root,
+                              gint       y_root)
 {
   if (!use_ole2_dnd)
     {
index a94a1885e2cacc89869fa84b5aee73194e1a18f7..f216d3816b2d5ebbe77c9c19fc9c97418b835bf4 100644 (file)
@@ -484,7 +484,7 @@ void       _gdk_win32_display_create_window_impl   (GdkDisplay    *display,
 
 /* stray GdkWindowImplWin32 members */
 void _gdk_win32_window_register_dnd (GdkWindow *window);
-GdkDragContext *_gdk_win32_window_drag_begin (GdkWindow *window, GdkDevice *device, GList *targets);
+GdkDragContext *_gdk_win32_window_drag_begin (GdkWindow *window, GdkDevice *device, GList *targets, gint x_root, gint y_root);
 gboolean _gdk_win32_window_simulate_key (GdkWindow      *window,
                                  gint            x,
                                  gint            y,
index d0c8757d960bf8b432e720a1a9ff6dfa30b5e22d..02d7e332362fb68db3cce08cea13d5aa714aa124 100644 (file)
@@ -1948,7 +1948,9 @@ create_drag_window (GdkScreen *screen)
 GdkDragContext *
 _gdk_x11_window_drag_begin (GdkWindow *window,
                             GdkDevice *device,
-                            GList     *targets)
+                            GList     *targets,
+                            gint       x_root,
+                            gint       y_root)
 {
   GdkDragContext *context;
 
index c2afecf46d158421367fa4ccff3d82af724710f8..f35d2af21d1b9288fb70dcaed961527612439acf 100644 (file)
@@ -312,7 +312,9 @@ void _gdk_x11_window_register_dnd (GdkWindow *window);
 
 GdkDragContext * _gdk_x11_window_drag_begin (GdkWindow *window,
                                              GdkDevice *device,
-                                             GList     *targets);
+                                             GList     *targets,
+                                             gint       x_root,
+                                             gint       y_root);
 
 gboolean _gdk_x11_get_xft_setting (GdkScreen   *screen,
                                    const gchar *name,